﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Paas.Infrastructure.Data.Migrations
{
    public partial class MetaFormFieldAddNavigationProperty2 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_MetaFormField_MetaField_MetaFieldId1",
                table: "MetaFormField");

            migrationBuilder.DropForeignKey(
                name: "FK_MetaFormField_MetaForm_MetaFormId1",
                table: "MetaFormField");

            migrationBuilder.DropIndex(
                name: "IX_MetaFormField_MetaFieldId1",
                table: "MetaFormField");

            migrationBuilder.DropIndex(
                name: "IX_MetaFormField_MetaFormId1",
                table: "MetaFormField");

            migrationBuilder.DropColumn(
                name: "MetaFieldId1",
                table: "MetaFormField");

            migrationBuilder.DropColumn(
                name: "MetaFormId1",
                table: "MetaFormField");

            migrationBuilder.AlterColumn<Guid>(
                name: "MetaFormId",
                table: "MetaFormField",
                type: "uniqueidentifier",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
                oldClrType: typeof(string),
                oldType: "nvarchar(max)",
                oldNullable: true);

            migrationBuilder.AlterColumn<Guid>(
                name: "MetaFieldId",
                table: "MetaFormField",
                type: "uniqueidentifier",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
                oldClrType: typeof(string),
                oldType: "nvarchar(max)",
                oldNullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_MetaFormField_MetaFieldId",
                table: "MetaFormField",
                column: "MetaFieldId");

            migrationBuilder.CreateIndex(
                name: "IX_MetaFormField_MetaFormId",
                table: "MetaFormField",
                column: "MetaFormId");

            migrationBuilder.AddForeignKey(
                name: "FK_MetaFormField_MetaField_MetaFieldId",
                table: "MetaFormField",
                column: "MetaFieldId",
                principalTable: "MetaField",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_MetaFormField_MetaForm_MetaFormId",
                table: "MetaFormField",
                column: "MetaFormId",
                principalTable: "MetaForm",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_MetaFormField_MetaField_MetaFieldId",
                table: "MetaFormField");

            migrationBuilder.DropForeignKey(
                name: "FK_MetaFormField_MetaForm_MetaFormId",
                table: "MetaFormField");

            migrationBuilder.DropIndex(
                name: "IX_MetaFormField_MetaFieldId",
                table: "MetaFormField");

            migrationBuilder.DropIndex(
                name: "IX_MetaFormField_MetaFormId",
                table: "MetaFormField");

            migrationBuilder.AlterColumn<string>(
                name: "MetaFormId",
                table: "MetaFormField",
                type: "nvarchar(max)",
                nullable: true,
                oldClrType: typeof(Guid),
                oldType: "uniqueidentifier");

            migrationBuilder.AlterColumn<string>(
                name: "MetaFieldId",
                table: "MetaFormField",
                type: "nvarchar(max)",
                nullable: true,
                oldClrType: typeof(Guid),
                oldType: "uniqueidentifier");

            migrationBuilder.AddColumn<Guid>(
                name: "MetaFieldId1",
                table: "MetaFormField",
                type: "uniqueidentifier",
                nullable: true);

            migrationBuilder.AddColumn<Guid>(
                name: "MetaFormId1",
                table: "MetaFormField",
                type: "uniqueidentifier",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_MetaFormField_MetaFieldId1",
                table: "MetaFormField",
                column: "MetaFieldId1");

            migrationBuilder.CreateIndex(
                name: "IX_MetaFormField_MetaFormId1",
                table: "MetaFormField",
                column: "MetaFormId1");

            migrationBuilder.AddForeignKey(
                name: "FK_MetaFormField_MetaField_MetaFieldId1",
                table: "MetaFormField",
                column: "MetaFieldId1",
                principalTable: "MetaField",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_MetaFormField_MetaForm_MetaFormId1",
                table: "MetaFormField",
                column: "MetaFormId1",
                principalTable: "MetaForm",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
    }
}
